package poketrade;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class BaseHttpServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;

	protected void forward(HttpServletRequest request, HttpServletResponse response, String page)
    {
	    try {
            request.getRequestDispatcher(page).forward(request, response);
	    } catch (ServletException e) {
            e.printStackTrace();
	    } catch (IOException e) {
            e.printStackTrace();
	    }
    }
	
	protected void showMessage(HttpServletRequest request, HttpServletResponse response, String message)
	{
		request.setAttribute("message", message);
		forward(request, response, "/message.jsp");
	}
    
    protected void redirect(HttpServletResponse response, String page)
    {
    	try {
    		response.sendRedirect(page);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
